package com.itheima.reggie.controller;

import com.itheima.reggie.common.R;
import com.itheima.reggie.entity.ShoppingCart;
import com.itheima.reggie.service.ShoppingCartService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * @author:YZN
 * @date:2023/1/7
 * @description:
 */
@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {

    @Autowired
    private ShoppingCartService shoppingCartService;

    @GetMapping("/list")
    public R list(){
        return shoppingCartService.shoppingList();
    }

    @PostMapping("/add")
    public R addCart(@RequestBody ShoppingCart shoppingCart){
        return shoppingCartService.addCart(shoppingCart);
    }


    @DeleteMapping("/clean")
    public R deleteCart(){
        return shoppingCartService.deleteCart();
    }

    @PostMapping("/sub")
    public R subCart(@RequestBody ShoppingCart shoppingCart){
        return shoppingCartService.subCart(shoppingCart);
    }
}
